<?php
ob_start();
include("common/connection.php");
$group=$_POST['group'];
$batch=$_POST['batch'];
$gender=$_POST['gender'];
$full_name=$_POST['full_name'];
$nick_name=$_POST['nick_name'];
$cell_phone=$_POST['cell_phone'];
$email=$_POST['email'];
$address=$_POST['address'];
$amount=$_POST['amount'];
$spouse=$_POST['spouse'];
$member=$_POST['member'];

//if($amount==1){$option="Option 1";}elseif($amount==2){$option="Option 2";}elseif($amount==3){$option="Option 3";}

$today = date("Y-m-d");
$fackId=10001;
//echo $originId=($fackId+$origin);

/*$qryUsercheck1= "SELECT * FROM `users` WHERE `verify`='".$_POST['id_no']."'";
$resultUsercheck1=mysql_db_query($db_name,$qryUsercheck1);
$rsUsercheck1=mysql_num_rows($resultUsercheck1);*/
$qryUsercheck2= "SELECT * FROM `users` WHERE `email`='".$_POST['email']."'";
$resultUsercheck2=mysql_db_query($db_name,$qryUsercheck2);
$rsUsercheck2=mysql_num_rows($resultUsercheck2);

//$id_num=substr($_POST['id_no'], -4, 1);

if($rsUsercheck2>0)
{
	/*if($rsUsercheck1)
	{
		header("Location: index.php?group=$group&batch=$batch&gender=$gender&full_name=$full_name&nick_name=$nick_name&cell_phone=$cell_phone&cell_phone1=$cell_phone1&email=$email&address=$address&amount=$amount&spouse=$amount&mess=1");
	}*/
	if($rsUsercheck2)
	{
		header("Location: index.php?group=$group&batch=$batch&gender=$gender&full_name=$full_name&nick_name=$nick_name&cell_phone=$cell_phone&cell_phone1=$cell_phone1&email=$email&address=$address&amount=$amount&spouse=$spouse&mess=2&nemail=7");
	}
	/*elseif($id_num==0)
	{
		header("Location: index.php?group=$group&batch=$batch&gender=$gender&full_name=$full_name&nick_name=$nick_name&cell_phone=$cell_phone&cell_phone1=$cell_phone1&email=$email&address=$address&amount=$amount&spouse=$amount&mess=3");
	}*/
	
}
else
{
  if($_POST['group']!=''&&$_POST['batch']!=''&&$_POST['gender']!=''&&$_POST['full_name']!=''&&$_POST['cell_phone']!=''&&$_POST['email']!=''&&$_POST['address']!=''&&$_POST['amount']!='')
  {
  $queryUser1="SELECT max(id) as id FROM `users`";
  $resultUser1=mysql_db_query($db_name,$queryUser1);
  $rsUser1=mysql_fetch_array($resultUser1);
  
  $originId=$fackId+$rsUser1[0]+1;
  
  echo $addUser="INSERT INTO `users` 		(`group`,`batch`,`gender`,`f_name`,`n_name`,`cell_num`,`email`,`address`,`spouse`,`member`,`amount`,`verify`,`created_date`) 
  VALUES 
  ('".$_POST['group']."','".$_POST['batch']."','".$_POST['gender']."','".$_POST['full_name']."','".$_POST['nick_name']."','".$_POST['cell_phone']."','".$_POST['email']."','".$_POST['address']."','".$_POST['spouse']."','".$_POST['member']."','".$_POST['amount']."','$originId','$today')";
  $resultUsers=mysql_db_query($db_name,$addUser);
  }

$queryUser="SELECT max(id) as id FROM `users`";
$resultUser=mysql_db_query($db_name,$queryUser);
$rsUser=mysql_fetch_array($resultUser);
$uid=$rsUser['id'];
//8888888888888888888888888888888888888888888jewel777777777777777
if ((($_FILES["photo"]["type"] == "image/gif")
|| ($_FILES["photo"]["type"] == "image/jpeg")
|| ($_FILES["photo"]["type"] == "image/jpg")
|| ($_FILES["photo"]["type"] == "image/tiff")
|| ($_FILES["photo"]["type"] == "image/pjpeg"))
&& ($_FILES["photo"]["size"] < 900000000))
{
	if ($_FILES["photo"]["error"] > 0)
	{
		header("location: error.html");
	}
	else
		{
			"Upload: " . $_FILES["photo"]["name"] . "<br />";
			"Type: " . $_FILES["photo"]["type"] . "<br />";
			"Size: " . ($_FILES["photo"]["size"] / 1024) . " Kb<br />";
			"Temp file: " . $_FILES["photo"]["tmp_name"] . "<br />";
			$ext = explode('.',$_FILES['photo']['name']);
			$ext2=substr(strrchr($_FILES['photo']['name'], "."),1);
			$extension = $ext[1];
			srand(time(0));
			$token=100000+rand()%(900000-100000);
			$newname=$token.'.'.$ext2;
			
			if (file_exists("upload/" . $newname))
			{
				echo $_FILES["photo"]["name"] . " already exists. ";
			}
			else
			{
				move_uploaded_file($_FILES["photo"]["tmp_name"],
				"upload/" . $newname);
				"Stored in: " . "upload/" . $_FILES["photo"]["name"];
				$sql="UPDATE `users` set photo ='$newname' where id=$uid";
				mysql_query($sql);
				//header("location: profile_page.php?id=$MyID");
			} 
		} 
}
//8888888888888888888888888888888888888888888jewel777777777777777
			  
			  
if($amount==1){$option="Registration as IBAAA Life Members";}
elseif($amount==2){$option="IBAAA Membership & Event Registration";}
elseif($amount==3){$option="Registration only for Event";}

$content="<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<style type='text/css'>  
    * html .outlook_radbutton_text_hover { width: auto !important; }  
    *+html .outlook_radbutton_text_hover { width: auto !important; }  
</style> 
</head>

<body style='margin: 0; padding: 0;'>
<div align='center'>

<table align='center' border='0' cellpadding='10' cellspacing='0' style='font-family:Verdana, Geneva, sans-serif; font-size:18px; font-weight:bold;'>
	<tr align='center' style='color:#000 !important;'>
		<td>Date<br>23rd March 2012</td>
		<td>Venue<br>Banani Bidyaniketan School premises</td>
		<td>Time<br>10am - 10pm</td>
	</tr>
</table>

<table cellpadding='0' cellspacing='0' border='0' align='center' width='85%'>

    <tr>
       	<td>
        	<p style='text-align:center; font-family:Verdana, Geneva, sans-serif; font-size:34px; color:#ff4b00;'>Thank you for your registration. </p>
        </td>
    </tr>
	<tr><td><p>&nbsp;</p></td></tr>
	<tr>
       	<td>
        	<p style='text-align:center; font-family:Verdana, Geneva, sans-serif; font-size:34px; color:#ff4b00;'>please pay your registration fees and collect your ticket within one week. </p>
        </td>
    </tr>
	<tr><td><p>&nbsp;</p></td></tr>
    <tr>
    	<td>
        
        	
            
            	<table align='center' cellpadding='0' cellspacing='0' width='75%' >
                	<tr style='font-size:20px;'>
                    	<td   align='center'>Name: $full_name</td>
                    </tr>
                    <tr style='font-size:20px;'>
                    	<td   align='center'>Cell No : $cell_phone</td>
                    </tr>
                    <tr style='font-size:20px;'>
                    	<td   align='center'>Reunion ID: <b>$originId</b></td>
                    </tr>
                    <tr style='font-size:20px;'>
                    	<td   align='center'>Amount to be paid: <b>$amount</b></td>
                    </tr>
                    <tr style='font-size:20px;'>
                    	<td   align='center'>Registration Option: $option</td>
                    </tr>
                    <tr style='font-size:20px;'>
                    	<td   align='center' style='padding-bottom:15px;'>Registered for Spouse: $option1</td>
                    </tr>
                                    
                </table>

        
        
        </td>
    </tr>
    <tr>
    	<td>
        	<h4 align='center'><b>If you're receiving this mail after you've done on-spot registration that means you haven't done online registration. In that case please ignore this mail. </b></h4>            
        </td>
    <tr>
    <tr><td><p>&nbsp;</p></td></tr>
<tr>
    	<td>
        	<h4 align='center'><b>PLEASE TRY TO BRING PRINT OUT OF THIS PAGE AT THE PAYMENT POINT </b></h4>            
        </td>
    <tr>
    <tr><td><p>&nbsp;</p></td></tr>
    <tr>
    	<td>
        	<h1 align='center' style='color:#ff4b00'>Payment Points</h1>
        </td>
    <tr>
    <tr>
    
    	<td>
        	
            
            	<table border='0' cellpadding='0' cellspacing='0' style='margin-left:40px; line-height:1.3;'>
                    	<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Banani Bidyaniketon,East School Building</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>1st Floor, waiting room</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>time : 11.00 am - 6.00pm</p></td>
                        </tr>
                        <tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Organizing President</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Amanul Haque</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01942915381 </p></td>
                        </tr>
						<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Nikunjo (2008 batch )</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Ahmed Shatil Ruhi</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01818037752 </p></td>
                        </tr>

						<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Banani (2008 batch)</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Riyadh Ahmed</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01670920662 </p></td>
                        </tr>

						<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Mohakhali (2008 batch)</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Mehedi Hasan Khan</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01750666981 </p></td>
                        </tr>

						<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Banani (2008 batch)</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Md. Ashiqur Rahman</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01676522609 </p></td>
                        </tr>

						<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Banani (2008 batch)</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Md. Arifuzzaman Jehan</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01714378200 </p></td>
                        </tr>

						<tr>
                        	<td class='namelocation' style='width:380px; font-weight:bold; color:#1D1D1D;'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Banani (2008 batch)</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>Farhat Aziz Sheen</p></td>
                            <td class='email_contact' style='width:200px; text-align:left'><p style='font-family:Verdana, Geneva, sans-serif; font-size:14px;'>01911484775 </p></td>
                        </tr>

						
                        </table>
        </td>
    </tr>
    <tr><td><p>&nbsp;</p></td></tr>
</table>
</div>
</body>
</html>";
//echo $content;

$subject="Banani Bidyaniketan: 40 Years Celebration & Reunion - 2012 REGISTRATION CONFIRMATION.";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Organization: www.webpers.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";

$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
// To send HTML mail, the Content-type header must be set

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: bidyaniketanbanani@gmail.com\n";
$email=$_POST['email'];
	if($email!='')
	{
		mail("$email","$subject","$content",$headers);
		header("Location: reg_success.php?id=$uid");
	}
	}
?>
